/**
 * @Auther: lichao
 * @Date: 2024/10/16 - 10 - 16 - 20:33
 * @Description: PACKAGE_NAME
 * @version: 1.0
 */

import java.util.StringJoiner;

/**
 * @program: java
 *
 * @description: StringJoiner 类的 length 方法
 *
 * @author: lichao
 *
 * @create: 2024-10-16 20:33
 **/

public class LengthTest {
    public static void main(String[] args) {
        /**
         * length 方法返回 StringJoiner 的长度
         * 但是如果没有添加数据则返回 prefix + suffix 或 emptyValue 的长度
         */
        StringJoiner sj = new StringJoiner(",");
        System.out.println(sj.length()); // 0

        StringJoiner sj2 = new StringJoiner(",", "[", "]");
        System.out.println(sj2.length()); // 2

        StringJoiner sj3 = new StringJoiner(",");
        sj3.setEmptyValue("测试 emptyValue 的长度");
        System.out.println(sj3.length()); // 17
    }
}
